package com.tandashi.springbootstudy01.service.user.impl;

import com.tandashi.springbootstudy01.entity.user.User;
import com.tandashi.springbootstudy01.service.user.UserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.StringUtils;

@Service
public class UserServiceImpl implements UserService {

    /*private UserDao userDao;

    public UserServiceImpl(UserDao userDao) {
        this.userDao = userDao;
    }*/

    @Override
    public User getUserById(Long id) {
        return new User(1L,"jay","1234");
    }

    @Override
    public User getUserByUserName(String loginName) {
        if(StringUtils.isEmpty(loginName)){
            return null;
        }
        return loginName.equals("jay")? new User(1L,"jay","1234"):null;
    }

    @Transactional(readOnly = true,transactionManager = "userTransactionManager")
    public String getAgentCodeByUnionId(String unionid) {
        return "00001072392";
    }
}
